// Converted from UnityScript to C# at http://www.M2H.nl/files/js_to_c.php - by Mike Hergaarden
// Do test the code! You usually need to change a few small bits.

using UnityEngine;
using System.Collections;

public class SpecialEffectHandler : MonoBehaviour
{
// Helper script to toggle the emit property of many particle systems.
// It's attached to the root Game Object of a hierarcy. Then calling SetSpecialEffectActive will
// enable or disable all particle systems in transform children.


// helper variable to track if the particles are already on.
	private bool effectActive;

	void SetSpecialEffectActive (bool @on)
	{
		
		// Only do something if we're actually changing the effects being on or off
		if (@on != effectActive) {
			
			// Find a list of all ParticleEmitters that are in this object's transform children
			ParticleEmitter[] childEmitters;
			childEmitters = GetComponentsInChildren<ParticleEmitter> ();
			
			// Go over all them
			foreach (ParticleEmitter emitter in childEmitters) {
				// turn them on or off
				emitter.emit = @on;
			}
			
			effectActive = @on;
		}
	}
	
	void Start() {
	}
	
}
